package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BuzTaskOption;
import com.ruoyi.system.service.IBuzTaskOptionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 题目可选项Controller
 * 
 * @author ruoyi
 * @date 2023-08-27
 */
@RestController
@RequestMapping("/system/buzTaskOption")
public class BuzTaskOptionController extends BaseController
{
    @Autowired
    private IBuzTaskOptionService buzTaskOptionService;

    /**
     * 查询题目可选项列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskOption:list')")
    @GetMapping("/list")
    public TableDataInfo list(BuzTaskOption buzTaskOption)
    {
        startPage();
        List<BuzTaskOption> list = buzTaskOptionService.selectBuzTaskOptionList(buzTaskOption);
        return getDataTable(list);
    }

    /**
     * 导出题目可选项列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskOption:export')")
    @Log(title = "题目可选项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BuzTaskOption buzTaskOption)
    {
        List<BuzTaskOption> list = buzTaskOptionService.selectBuzTaskOptionList(buzTaskOption);
        ExcelUtil<BuzTaskOption> util = new ExcelUtil<BuzTaskOption>(BuzTaskOption.class);
        util.exportExcel(response, list, "题目可选项数据");
    }

    /**
     * 获取题目可选项详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskOption:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(buzTaskOptionService.selectBuzTaskOptionById(id));
    }

    /**
     * 新增题目可选项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskOption:add')")
    @Log(title = "题目可选项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BuzTaskOption buzTaskOption)
    {
        return toAjax(buzTaskOptionService.insertBuzTaskOption(buzTaskOption));
    }

    /**
     * 修改题目可选项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskOption:edit')")
    @Log(title = "题目可选项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BuzTaskOption buzTaskOption)
    {
        return toAjax(buzTaskOptionService.updateBuzTaskOption(buzTaskOption));
    }

    /**
     * 删除题目可选项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskOption:remove')")
    @Log(title = "题目可选项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(buzTaskOptionService.deleteBuzTaskOptionByIds(ids));
    }
}
